<?php

require_once(config::getDocRoot().'lib/adodb5/adodb.inc.php');

class umDb{
	private static $db;
	
	public static function setDebug($bool){
		self::$db->debug=$bool;
	}
	
	/**
	 * get database object
	 * 
	 * @throws Exception
	 * @return ADOConnection
	 */
	public static function getDb(){
		if(empty(self::$db)) self::initDb();
		
		if(!is_object(self::$db)) throw new Exception('INVALID DB REQUESTED');
		
		return self::$db;
	}
	
	private static function initDb(){
		self::$db = NewADOConnection(config::DB_DRIVER.'://'.config::DB_USER.':'.config::DB_PASSWORD.'@'.config::DB_HOST.'/'.config::DB_DATABASE);
	}
}

